package com.yly.doctorapp.picturebrowser;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.widget.ImageView;
import android.widget.TextView;

import com.yly.doctorapp.R;
import com.yly.doctorapp.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * ProjectName: SmartBus
 * PackageName: com.zhcx.smartbus.ui.picturebrowser
 * description:
 * Date：2018/1/31 14:56
 * Author：Steven J
 * ClassName:图片浏览器
 * Modify The Note:
 **/

public class PictureBrowserActivity extends BaseActivity {
    @BindView(R.id.image_clear)
    ImageView mImageClear;
    @BindView(R.id.view_page)
    ViewPager mViewPage;
    @BindView(R.id.text_num)
    TextView mTextNum;
    private List<String> mImageUrlList = new ArrayList<>();
    private int pos = 0;
    private PictureAdapter mPictureAdapter;

    @Override
    protected int getNaviteColor() {
        return R.color.black;
    }

    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_picturebrowser;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mImageUrlList = getIntent().getStringArrayListExtra("FILELISTURL");
        pos = getIntent().getIntExtra("INDEX", 0);
        mPictureAdapter = new PictureAdapter(PictureBrowserActivity.this, mImageUrlList);
        mViewPage.setAdapter(mPictureAdapter);
        mViewPage.setCurrentItem(pos);//设置起始位置
        mViewPage.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                mTextNum.setText((position + 1) + "/" + mImageUrlList.size());//显示当前图片的位置
            }

            @Override
            public void onPageSelected(int position) {

            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

    @Override
    protected void initData() {

    }

    @OnClick(R.id.image_clear)
    public void onViewClicked() {
        finish();
    }
}
